	#include("/common/include/pageTitleBread.html")
	<div id="page-content">
			<div class="col-lg-12">
		        <div class="panel">
		        	#if(procInsId)
		            <div class="panel-heading">		            
		                <h3 class="panel-title">		                	
		                		<a href="#(ctx)/processEditor/diagram-viewer/index.html?processDefinitionId=#(defId)&processInstanceId=#(o.proc_ins_id)" target="_blank" style="position: absolute;right: 80px">
			                		<button class="btn btn-info" type="button">审批流程</button>
			                	</a>
			                	<a href="javascript:void(0);" onclick="pointLion.openTaskHisListPage('#(procInsId)')" style="position: absolute;right: 150px">
			                		<button class="btn btn-success" type="button">审批历史</button>
			                	</a>		                	
		                </h3>
		            </div>
		            #end
		            <form id="editForm" class="panel-body form-horizontal form-padding">
		            	<input type="hidden" name="business.id" value="#(o?o.id:'')">
		            	<input type="hidden" name="taskid" value="#(task?task.TASKID:'')">
		            	<div class="form-group">
		                    <label class="col-md-2 control-label" for="dxt-input">申请人</label>		                    
		                    <div class="col-md-3">
		                    	<input type="hidden" name="business.sender_id" value="#(o.sender_id)">
		                        <input type="text"  id="business_sender_name"  name="business.sender_name" value="#(o.sender_name)" readonly class="form-control">
		                    </div>
		                </div>
		                <div class="form-group">
		                	<label class="col-md-2 control-label " for="demo-text-input">付款明细</label>
		                	<div class="col-md-4">
		                	<div class="col-md-5" style='padding-left:5px;padding-bottom:10px;'>
				                    <select class="selectpicker #if(view=="detail"||view=="auth") hidden #end" id="business_type" onchange="onTypeChange()" >
		                                <option value="">---付款类型---</option>
		                                <option value="专家课酬">专家课酬 </option>
		                                <option value="专家演讲费">专家演讲费 </option>
		                                <option value="专家分成">专家分成</option>
		                                <option value="供应商付款">供应商付款</option>
		                                <option value="实习生付款">实习生付款</option>
		                                <option value="PUGC付款">PUGC付款</option>
		                                <option value="内部人员差旅及补贴">内部人员差旅及补贴</option>
		                                <option value="其他">其他</option>
		                            </select>
		                	</div>
		                    <div class="col-md-5">
		                        <input type="number" id="pay_price"  class="form-control #if(view=="detail"||view=="auth") hidden #end" placeholder="付款金额(元)"  #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                    <div class="col-md-2">
		                    <div class="btn btn-primary #if(view=="detail"||view=="auth") hidden #end" onclick="addDetail()">添加</div>
		                    </div>
		                	<table id="pay_price_detail_table"></table>
		                	<input id="pay_price_details" name="business.pay_detail" type="hidden" value="#(o?o.pay_detail:'')"/>
		                	</div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">课程品类</label>
		                    <div class="col-md-3" style="padding-left: 15px;">		                        
		                        <select class="selectpicker" id="business_subject_category" name="business.subject_category" onchange="onCategoryChange()" class="form-control"  #if(view=="detail"||view=="auth") disabled #end>
		                                <option value="柑橘">柑橘</option>
		                                <option value="葡萄">葡萄</option>
		                                <option value="猕猴桃">猕猴桃</option>
		                                <option value="芒果">芒果</option>
		                                <option value="苹果">苹果</option>
		                                <option value="草莓">草莓</option>
		                                <option value="火龙果">火龙果</option>
		                                <option value="蔬菜">蔬菜</option>
		                                <option value="百香果">百香果</option>
		                                <option value="桃子">桃子</option>
		                                <option value="其他">其他</option>		                                
		                            </select>
		                            <script>
		                            </script>
		                    </div>
		                    <label class="col-md-1 control-label" for="demo-text-input">课程编码</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.subject_code" class="form-control" placeholder="IBOS对应课程编号,多个【;】分隔" value="#(o?o.subject_code:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                </div>
		                <div class="form-group">
		                <label class="col-md-2 control-label" for="demo-text-input">付款名称</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.pay_title" class="form-control"  value="#(o?o.pay_title:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                    
		                 </div>
		                 <!-- <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">拍课人员交通费(元)</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.car_fare" class="form-control"  value="#(o?o.car_fare:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                    <label class="col-md-1 control-label" for="demo-text-input">拍课人员补贴(元)</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.subsidy" class="form-control"  value="#(o?o.subsidy:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                </div>
		                 -->		               
		                 <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">付款描述</label>
		                    <div class="col-md-8">
		                        <textarea name="business.pay_desc" rows="6" class="form-control" #if(view=="detail"||view=="auth") readonly #end>#(o?o.pay_desc:'')</textarea>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">受益人</label>
		                    <div class="col-md-3" >		                  
		                    	<input type="text"  id="business_beneficiary" name="business.beneficiary" placeholder="请输入受益人" class="form-control"  value="#(o?o.beneficiary:'')" #if(view=="detail"||view=="auth") disabled #end/>      
		                        <!-- <select id="business_beneficiary" name="business.beneficiary" placeholder="请选择受益专家或老师"  class="form-control selectpicker" data-live-search="true" data-width="100%" height="200px" value="#(o?o.beneficiary:'')" #if(view=="detail"||view=="auth") disabled #end>
					                                <option value="付老师">付老师</option>
													<option value="何文忠">何文忠</option>
													<option value="余涛">余涛</option>
													<option value="凌永河">凌永河</option>
													<option value="刁金玲">刁金玲</option>
													<option value="刘升球">刘升球</option>
													<option value="刘爱林">刘爱林</option>
													<option value="卢文彝">卢文彝</option>
													<option value="吕不白">吕不白</option>
													<option value="吕岩">吕岩</option>
													<option value="吕雅丽">吕雅丽</option>
													<option value="吴理慧">吴理慧</option>
													<option value="吴老三">吴老三</option>
													<option value="周从清">周从清</option>
													<option value="周健">周健</option>
													<option value="唐计刚">唐计刚</option>
													<option value="岑红梅">岑红梅</option>
													<option value="张倩">张倩</option>
													<option value="张大萍">张大萍</option>
													<option value="张戈壁">张戈壁</option>
													<option value="张钦书">张钦书</option>
													<option value="张锡炎">张锡炎</option>
													<option value="张锦松">张锦松</option>
													<option value="徐明举">徐明举</option>
													<option value="曹立">曹立</option>
													<option value="李世松">李世松</option>
													<option value="李丙智、张立功">李丙智、张立功</option>
													<option value="李丙智">李丙智</option>
													<option value="李恩伟">李恩伟</option>
													<option value="李春雨">李春雨</option>
													<option value="杨争光">杨争光</option>
													<option value="林崇彩">林崇彩</option>
													<option value="梁桂东">梁桂东</option>
													<option value="梅强">梅强</option>
													<option value="毕慧芳">毕慧芳</option>
													<option value="潘华漂">潘华漂</option>
													<option value="熊玉林">熊玉林</option>
													<option value="王小宇">王小宇</option>
													<option value="王进军">王进军</option>
													<option value="班疆宁">班疆宁</option>
													<option value="石嫣">石嫣</option>
													<option value="章明念">章明念</option>
													<option value="胡化立">胡化立</option>
													<option value="胡海卿">胡海卿</option>
													<option value="莫刚凡">莫刚凡</option>
													<option value="莫文珍">莫文珍</option>
													<option value="莫贤龙">莫贤龙</option>
													<option value="葛长富">葛长富</option>
													<option value="衡涛">衡涛</option>
													<option value="西拉">西拉</option>
													<option value="观麦">观麦</option>
													<option value="谢秀挺">谢秀挺</option>
													<option value="谷风">谷风</option>
													<option value="贾旭">贾旭</option>
													<option value="贾磊">贾磊</option>
													<option value="车旭涛、李春雨">车旭涛、李春雨</option>
													<option value="邓子牛">邓子牛</option>
													<option value="邓子牛、邓烈、邓晓玲">邓子牛、邓烈、邓晓玲</option>
													<option value="邓晓玲">邓晓玲</option>
													<option value="邓烈">邓烈</option>
													<option value="邓铁军">邓铁军</option>
													<option value="钟善东">钟善东</option>
													<option value="阳廷密">阳廷密</option>
													<option value="陈统奎">陈统奎</option>
													<option value="黄志强">黄志强</option>
					                            </select> -->
		                    </div>
		                    <label class="col-md-1 control-label" for="demo-text-input">身份证号码</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.id_card" class="form-control"  value="#(o?o.id_card:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">银行账户</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.bank_card" class="form-control"  value="#(o?o.bank_card:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                </div>		                            							
                         <div class="form-group input-daterange" id="datepicker">
                         <label class="col-md-2 control-label" for="demo-text-input">录课开始日期</label>
                         <div class="col-md-3">
                             <input type="text" name="business.start_date" class="form-control" value="#(o?o.start_date:'')" #if(view=="detail"||view=="auth") disabled #end />
                         </div>
                             <label class="col-md-1 control-label" for="demo-text-input">录课结束日期</label>
                             <div class="col-md-3">
                             <input type="text" name="business.end_date" class="form-control" value="#(o?o.end_date:'')" #if(view=="detail"||view=="auth") disabled #end />
                             </div>
                         </div>					 
		                <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">录课总时长(分钟)</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.subject_min" class="form-control"  value="#(o?o.subject_min:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                    <label class="col-md-1 control-label" for="demo-text-input">录课地点</label>
		                    <div class="col-md-3">
		                        <input type="text"  name="business.address" class="form-control" placeholder="请输入录课地点，省市县乡镇" value="#(o?o.address:'')" #if(view=="detail"||view=="auth") readonly #end />
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">摄影师</label>
		                    <div class="col-md-3" style="padding-left: 15px;">		                        
		                        <select class="selectpicker" name="business.cameraman" id="business_cameraman" value="#(o?o.cameraman:'')" #if(view=="detail"||view=="auth") disabled #end>
		                                <option value="吴佳磊">吴佳磊 </option>
		                                <option value="张顺杰">张顺杰</option>
		                                <option value="陈彬">陈彬</option>
		                                <option value="俞治豪">俞治豪 </option>
		                                <option value="周星宇">周星宇</option>
		                                <option value="其他">其他</option>
		                            </select>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">备注</label>
		                    <div class="col-md-8">
		                        <textarea  name="business.remark"  rows="6" class="form-control" #if(view=="detail"||view=="auth") readonly #end>#(o?o.remark:'')</textarea>
		                    </div>
		                </div>
		                <div class="form-group">
			                <label class="col-md-2 control-label" for="demo-text-input">附件</label>
			                <div class="col-md-8">
			                   <div id="uploader-demo">
			                     	#if(view!="detail"&&view!="auth") 
								    <label id="filePicker">选择文件(仅支持单个)</label>
								    #end
							    	<div id="fileList" class="uploader-list">
							    	#if(o.attachment)
							    		<a href="#(ctx)/admin/upload/download?path=#(o.attachment)">#(o.attachment)</a>
							    	#end
							    	</div>
								</div>
			                 </div>
			                 <input type="hidden" id="filePath" name="business.attachment" value="#(o?o.attachment:'')">
			             </div>
			              <div class="form-group">
		                    <label class="col-md-2 control-label" for="demo-text-input">课程组审批人</label>
		                    <div class="col-md-3">		                        
		                        <select class="selectpicker" id="business_author1" name="business.author1" value="#(o?o.author1:'')" #if(view=="detail"||view=="auth") disabled #end>
		                        		#for(lmuser:lmUsers)
		                                <option value="#(lmuser.username)">#(lmuser.name)</option>
		                                #end
		                            </select>
		                    </div>
		                    <label class="col-md-1 control-label" for="demo-text-input">商务经理</label>
		                    <div class="col-md-3">		                        
		                        <select class="selectpicker" id="business_author2"  name="business.author2" value="#(o?o.author2:'')" #if(view=="detail"||view=="auth") disabled #end>
		                        		#for(bduser:bdUsers)
		                                <option value="#(bduser.username)">#(bduser.name)</option>
		                                #end
		                            </select>
		                    </div>
		                </div>
		                #if(view!="detail"&&view!="auth") 
			                <div class="panel-footer">
			                    <div class="row">
			                        <div class="col-sm-9 col-sm-offset-3">
			                            <button class="btn btn-warning" type="reset">重置</button>
			                            <button class="btn btn-mint" type="submit" >保存</button>
			                        </div>
			                    </div>
			                </div>
			            #end
			            #if(view=="auth") 
				             <div class="form-group">
			                    <label class="col-md-2 control-label" for="demo-text-input">审核意见</label>
			                    <div class="col-md-8">
			                        <textarea id="comment" name="comment" rows="12" class="form-control"></textarea>
			                    </div>
			                </div>
			                <div class="panel-footer">
			                    <div class="row">
			                        <div class="col-sm-9 col-sm-offset-3">
				                            <button class="btn btn-danger" type="button" onclick="completeTask(false)">驳回</button>
				                            <button class="btn btn-mint" type="button" onclick="completeTask(true)">同意</button>
			                        </div>
			                    </div>
			                </div>
			            #end
		            </form>
		        </div>
		    </div>
	</div>
	<script>
	 $('.input-daterange').datepicker({
	     format: "yyyy-mm-dd",
	     todayBtn: "linked",
	     autoclose: true,
	     todayHighlight: true,
	     language: "zh-CN"
	 });	 
	 
	 //$("#ttttt").find("option[text='火龙果']").attr("selected",true);
	 $("#business_subject_category").val("#(o?o.subject_category:'')");
	 $("#business_beneficiary").val("#(o?o.beneficiary:'')");
	 $("#business_cameraman").val("#(o?o.cameraman:'')");
	 if('#(o?o.author1:'')' == '')
		 $("#business_author1").val("宋金龙");
	 else
	 	$("#business_author1").val("#(o?o.author1:'')");
	 
	 if('#(o?o.author2:'')' == '')
	 	$("#business_author2").val("吴禹");
	 else
	 	$("#business_author2").val("#(o?o.author2:'')");
	 
	 	function onTypeChange()
	 	{
	 		var btype =$('#business_type').val();
	 			 		
	 		if(btype=="内部人员差旅及补贴")
	 		{
	 			$('#business_beneficiary').val($('#business_sender_name').val());
	 		}
	 	}
	 	
	 	function onCategoryChange()
	 	{
	 		var category =$('#business_subject_category').val();
		 	
	 		switch(category)
	 		{
		 		case "柑橘":
		 		case "蔬菜":
		 			$('#business_author1').val("宋金龙");
		 			$('#business_author2').val("吴禹");
		 			break;
		 		case "苹果":
		 			$('#business_author1').val("彭斯媛");
		 			$('#business_author2').val("叶小康");
		 			break;
		 		case "百香果":
		 			$('#business_author1').val("宋金龙");
		 			$('#business_author2').val("叶小康");
		 			break;
		 		case "葡萄":
		 		case "芒果":
		 			$('#business_author1').val("窦文祥");
		 			$('#business_author2').val("费文超");
		 			break;
		 		case "猕猴桃":
		 			$('#business_author1').val("宋金龙");
		 			$('#business_author2').val("吕纬");
		 			break;
		 		case "草莓":
		 			$('#business_author1').val("彭斯媛");
		 			$('#business_author2').val("吕纬");
		 			break;
		 		default:
		 			break;
	 		}
	 		
	 		$('#business_author1').selectpicker('refresh');
	 		$('#business_author2').selectpicker('refresh');
	 	}
	 	
		function save(){
			var data = common_ajax.ajaxFunc("/admin/business/applySave", $('#editForm').serialize(), "json", null);
			if(data.success){
				pointLion.alertMsg("保存成功!" , "success" , "small" , function(){
					doPjax(ctx+'/admin/business/apllyPage');//跳转到列表页
				});
			}
		}
		function completeTask(pass){
			if(!$('#comment').val()){
				pointLion.alertMsg("审批意见不能为空" , "danger" , "small" , null);
				return;
			}
			var data = common_ajax.ajaxFunc("/admin/business/businessSubmit?pass="+pass, $('#editForm').serialize(), "json", null);
			if(data.success){
				pointLion.alertMsg(data.message , "success" , "small" , function(){
					doPjax(ctx+'/admin/business/apllyPage');
				});
			}else{
				pointLion.alertMsg(data.message , "danger" , "small" , null);
			} 
		}
		//表单校验
		function formValidate(){
			$('#editForm').bootstrapValidator({
	    		excluded:[":disabled"],
	            fields: {
	            	"business.bank_card": {
	                    validators: {
	                    	regexp: {
	                            regexp: /^[0-9]+$/,
	                            message: '银行账户请输入数字'
	                        }
	                    }
	                },
	                "business.id_card": {
	                    validators: {
	                    	regexp: {
	                            regexp: /^[0-9xX]+$/,
	                            message: '身份证号请输入数字或x'
	                        }
	                    }
	                },
	                "business.subject_category": {
	                    validators: {
	                        notEmpty: {
	                            message: '*课程品类不能为空'
	                        }
	                    }
	                },
	            	"business.subject_code": {
	                    validators: {
	                        notEmpty: {
	                            message: '*课程编码不能为空'
	                        }
	                    }
	                },
	                "business.pay_title": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*付款名称不能为空'
	                        }
	                    }
	                },
	                "business.pay_desc": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*付款描述不能为空'
	                        }
	                    }
	                },
	                "business.beneficiary": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*受益人不能为空'
	                        }
	                    }
	                },
	                "business.star_date": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*录课开始日期不能为空'
	                        }
	                    }
	                },
	                "business.end_date": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*录课结束日期不能为空'
	                        }
	                    }
	                },
	                "business.subject_min": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*录课总时长不能为空'
	                        },
	                        regexp: {
	                            regexp: /^[0-9.]+$/,
	                            message: '录课总时长请输入数字'
	                        }
	                    }
	                },
	                "business.address": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*录课地点不能为空'
	                        }
	                    }
	                },
	                "business.cameraman": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*摄影师不能为空'
	                        }
	                    }
	                },
	                "business.pay_price": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*付款金额不能为空'
	                        },
	                        regexp: {
	                            regexp: /^[0-9.]+$/,
	                            message: '付款金额请输入数字'
	                        }
	                    }
	                },
	                /*
	                "business.subsidy": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*补贴不能为空'
	                        },
	                        regexp: {
	                            regexp: /^[0-9.]+$/,
	                            message: '补贴请输入数字'
	                        }
	                    }
	                },
	                "business.car_fare": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*交通费不能为空'
	                        },
	                        regexp: {
	                            regexp: /^[0-9.]+$/,
	                            message: '交通费请输入数字'
	                        }
	                    }
	                },*/
	                "business.author1": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*课程组审批人不能为空'
	                        }
	                    }
	                },
	                "business.author2": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*商务经理不能为空'
	                        }
	                    }
	                },
	                "comment": {
	                    validators: {
	                    	notEmpty: {
	                            message: '*审批意见不能为空'
	                        }
	                    }
	                }
	            }
	        }).on("success.form.bv", function (e) {
	        	//校验付款明细
	        	if(payDetailDatas.length==0){
	        		alert("付款明细不能为空");
	        		return false;
	        	}
	        	$('#pay_price_details').val(JSON.stringify(payDetailDatas).replace(/\"/g,"'"));
	            save();
	            return false;//阻止表单跳转
	        });
		};
		
		//付款详情明细
		var payDetailDatas=[];
		$('#pay_price_detail_table').bootstrapTable({
		    columns: [{  
		        title: '序号',  
		        field: '',  
		        align:'center',
		        formatter: function (value, row, index) {  
		            return index+1;  
		        }  
		    } , {
		        field: 'type',
		        title: '付款类型',
		        align:'center'
		    }, {
		        field: 'price',
		        title: '付款金额(元)',
		        align:'center'
		    }
		    #if(!(view=="detail"||view=="auth")) 
		    ,{field: 'deleted',title: '操作', align:'center',formatter:function(value,row,index){
			       return '<a class="label label-table label-danger" onclick="deleteDetail(\''+index+'\')" href="javascript:void(0);" >删除</a>';
			    }}
		    #end 
		    ],
		    data: []
		});
		
		$(document).ready(function() {
			$(".selectpicker").selectpicker({});
			$(".bootstrap-select").attr("style","width:100%;");
			formValidate();
			//初始化上传组件
			pointLion.initUploader("filePath");
			//初始化付款详细
			var initPayDetail=$('#pay_price_details').val();
			if(initPayDetail){
				payDetailDatas=	JSON.parse(initPayDetail.replace(/\'/g,'"'));
				$('#pay_price_detail_table').bootstrapTable('load', payDetailDatas);
			}
		});
		
		
	var _businessTypeDom=$('#business_type');
	var _payPriceDom=$('#pay_price');
	function addDetail(){
		if(!_businessTypeDom.val()||!_payPriceDom.val()){
			return;
		}
		var addRowData={type:_businessTypeDom.val(),price:_payPriceDom.val()};
		payDetailDatas.push(addRowData);
		_payPriceDom.val('');
		$('#pay_price_detail_table').bootstrapTable('load', payDetailDatas);
	}
	function deleteDetail(index){
		payDetailDatas.splice(index,1);
		$('#pay_price_detail_table').bootstrapTable('load', payDetailDatas);
	}
	</script>